<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>学生信息管理系统</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            max-width: 800px;
            margin: 0 auto;
            padding: 20px;
            background-color: #f5f5f5;
        }

        h1 {
            text-align: center;
            color: #333;
        }

        form {
            display: flex;
            flex-direction: column;
            align-items: center;
            margin-bottom: 20px;
        }

        label {
            margin-bottom: 5px;
        }

        input {
            margin-bottom: 10px;
        }

        button {
            background-color: #4CAF50;
            color: white;
            padding: 10px 20px;
            border: none;
            cursor: pointer;
            text-align: center;
            text-decoration: none;
            display: inline-block;
            font-size: 16px;
            margin: 4px 2px;
            transition-duration: 0.4s;
        }

        button:hover {
            background-color: #45a049;
        }

        table {
            width: 100%;
            border-collapse: collapse;
        }

        th, td {
            padding: 10px;
            text-align: left;
            border-bottom: 1px solid #9913f3; 
        }

        tr:nth-child(even) {
            background-color: #0be4d2;
        }
        tbody tr:nth-child(odd) {
        background-color:rgb(13, 225, 240);
    }
    </style>
</head>
<body>
    <h1>学生信息管理系统</h1>
    <form id="studentForm">
        <label for="name">姓名：</label>
        <input type="text" id="name" required>
        <br>
        <label for="age">年龄：</label>
        <input type="number" id="age" required>
        <br>
        <label for="gender">性别：</label>
        <select id="gender">
            <option value="男">男</option>
            <option value="女">女</option>
        </select>
        <br>
        <button type="submit">添加学生</button>
    </form>
    <h2>学生列表</h2>
    <table id="studentTable">
        <thead>
            <tr>
                <th>姓名</th>
                <th>年龄</th>
                <th>性别</th>
            </tr>
        </thead>
        <tbody>
        </tbody>
    </table>
    <script src="app.js"></script>
</body>
<script>
    document.getElementById('studentForm').addEventListener('submit', function (event) {
    event.preventDefault();

    const name = document.getElementById('name').value;
    const age = document.getElementById('age').value;
    const gender = document.getElementById('gender').value;

    const student = {
        name: name,
        age: age,
        gender: gender
    };

    addStudent(student);
});

function addStudent(student) {
    const studentList = document.getElementById('studentTable').getElementsByTagName('tbody')[0];
    const listItem = document.createElement('tr');
    listItem.innerHTML = `<td>${student.name}</td><td>${student.age}</td><td>${student.gender}</td>`;
    studentList.appendChild(listItem);
}

</script>
</html>
